<?php


class WSB_View_Helper_FormMultiSelect extends Zend_View_Helper_FormSelect
{

	/**
	 * @param string $name
	 * @param string $value
	 * @param array $attribs
	 * @param array $options
	 * @return string
	 */
    public function formMultiSelect($name, $value = null, $attribs = null, $options = null)
    {
        $info = $this->_getInfo($name, $value, $attribs, $options);
        extract($info); // name, id, value, attribs, options, listsep, disable

    	$translate = Zend_Registry::get('Zend_Translate');

		$ams = new HTML_QuickForm_advmultiselect($name, null, $options, $attribs);

		// Setze ausgewaehlte Elemente
		$ams->setValue($value);
		$ams->setLabel(array(null, $translate->_('unassigned'), $translate->_('assigned')));
		$ams->setButtonAttributes('add',    array('value' => html_entity_decode('<< ' . $translate->_('add')),
		                                           'class' => 'inputCommand'
		));
		$ams->setButtonAttributes('remove', array('value' => $translate->_('remove') . ' >>',
		                                           'class' => 'inputCommand'
		));

		$template = '
		<table{class}>
		<!-- BEGIN label_2 --><tr><th align="center">{label_3}</th><!-- END label_2 -->
		<!-- BEGIN label_3 --><th align="center">{label_2}</th></tr><!-- END label_3 -->
		<tr>
		  <td>{selected}</td>
		  <td>{unselected}</td>
		</tr>
		<tr>
		  <td align="center">{remove}</td>
		  <td align="center">{add}</td>
		</tr>
		</table>';
		$ams->setElementTemplate($template);

    	$html = '';
		$html .= $ams->getElementJs(false);
		$html .=  $ams->toHtml();

		return $html;

    }
}
